package net.srcz.jsjvm.core;

import java.io.FileReader;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;

import au.com.bytecode.opencsv.CSVReader;

public class CsvParser {

	public static Map<Integer,String> load() throws IOException {
		Map<Integer,String> map = new HashMap<Integer,String>();
		
		CSVReader reader = new CSVReader(new FileReader("./mnemonics.csv"),';');
	    String [] data;
	    while ((data = reader.readNext()) != null) {
	        // nextLine[] is an array of values from the line
	    	if(data.length < 3)
				continue;
			map.put(Integer.parseInt(data[0]),data[2]);
		}
		reader.close();
		return map;
	}
	
	static Map<Integer,String> opcodesJs;
	static {
		try {
			opcodesJs = load();
		} catch (IOException e) {
			throw new RuntimeException(e);
		}
	}
	
	public static void main(String[] args) {
		try {
			System.out.println(load());
		} catch(Exception ex) {
			ex.printStackTrace();
		}
	}
	
}
